//
//  WSAskTabViewCell.m
//  RunningMan
//
//  Created by 王帅 on 16/5/19.
//  Copyright © 2016年 WSJ. All rights reserved.
//

#import "WSAskTabViewCell.h"
#import "WSMyTool.h"
@interface WSAskTabViewCell ()
@property (nonatomic, strong) UIImageView *imageViewPhoto;
@property (nonatomic, strong) UILabel *lableTitle;
@property (nonatomic, strong) UILabel *labelAuthor;
@property (nonatomic, strong) UILabel *lableCommentCount;

@end

@implementation WSAskTabViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return self;
}
- (void)createSubView {
    self.imageViewPhoto = [[UIImageView alloc] init];
    [self.contentView addSubview:self.imageViewPhoto];

    self.lableTitle = [[UILabel alloc] init];
    self.lableTitle.font = [UIFont boldSystemFontOfSize:19];
    [self.contentView addSubview:self.lableTitle];
    
    self.labelAuthor = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelAuthor];
    
    self.lableCommentCount = [[UILabel alloc] init];
    [self.contentView addSubview:self.lableCommentCount];
    
}
- (void)layoutSubviews {
    [super layoutSubviews];
    self.imageViewPhoto.frame = CGRectMake(10, 30, CELLWIDTH - 20, 220);
    
    self.lableTitle.frame = CGRectMake(10, 5, CELLWIDTH - 20, 13);
    self.labelAuthor.frame = CGRectMake(10, 265, 200, 13);
    self.lableCommentCount.frame = CGRectMake(330, 265, 100, 13);
}
- (void)setModel:(Infos *)model {
    _model = model;
    NSArray *arr = [model.photo componentsSeparatedByString:@"/"];
    NSString *str = [arr componentsJoinedByString:@".fit-time.cn/"];
    NSString *str1 = @"http://";
    NSString *url = [str1 stringByAppendingString:str];
    [self.imageViewPhoto sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"允儿副本"]];
    
    self.lableTitle.text = model.title;
    self.labelAuthor.text = model.author;
    self.lableCommentCount.text = [NSString stringWithFormat:@"评论: %@", model.commentCount];
}

@end
